using BepInEx;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace LDBWeb
{
    [BepInPlugin("com.zhongpengcheng", "LDB-Web", "1.0.0")]
    [BepInProcess("DSPGAME.exe")]
    public class WebApplication : BaseUnityPlugin
    {
        /**
         * 初始化后台
         */
        private void Start()
        {
            Run(new string[0]);
        }

        /**
         * 启动MVC上下文
         */
        private static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });

        
        /**
         * 静态的上下文运行方法，可以再外部直接调用本方法启动后台
         */
        public static void Run(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }
    }
}